/**
 * @author dhl@oopsplay.org
 *
 */
package controllers;

import models.Question;
import play.mvc.Controller;

public class Admin extends Controller {
	public static void quesPage(){
		render();
	}
	
	
	//增加题目
	public static void addQuestion(String question,String answer){
		
		validation.required(question).message("题目不能为空");
		validation.required(answer).message("答案不能为空");
		if(!validation.hasErrors()){
			Question ques=new Question(question,answer).save();
			if(ques.isPersistent()){
				renderText("添加成功");
			}
			
			renderText("添加失败");
		}else{
			renderText(validation.errors().get(0));
		}
		
		
	}
}
